﻿--员工搜索
CREATE proc [dbo].[proc_Employee_Dimission_GetSearchList]
(
	@searchTex nvarchar(50),
	@username nvarchar(50)
)
as

--公司Id
declare @companyid nvarchar(4)
set @companyid = (select CompanyId from aspnet_Users where username=@username)

if(@searchTex='')
	set @searchTex='.'

	select 
		 id
		,EName
		,Enumber
		,ETempNumber
		,Sex
		,CompanyId
		,(select companyname from company where id=CompanyId) as CompanyName
		,DepartmentId
		,(select dname from Department where id=DepartmentId) as DName
		,PostId
		,(select PostName from post where id=postid) as PostName
		,IDCard
		,(select title from Grade where id=gradeid) as GradeName
		,Pluralist
	
	from employee where companyid=@companyid and ename like '%'+@searchTex+'%' and departmentid is not null

RETURN